package net.minecraft.server;

import java.util.Random;

public class BlockSapling extends BlockFlower
{
  protected BlockSapling(int paramInt1, int paramInt2)
  {
    super(paramInt1, paramInt2);

    float f = 0.4F;
    a(0.5F - f, 0.0F, 0.5F - f, 0.5F + f, f * 2.0F, 0.5F + f);
  }

  public void a(World paramWorld, int paramInt1, int paramInt2, int paramInt3, Random paramRandom) {
    super.a(paramWorld, paramInt1, paramInt2, paramInt3, paramRandom);

    if ((paramWorld.getLightLevel(paramInt1, paramInt2 + 1, paramInt3) >= 9) && 
      (paramRandom.nextInt(30) == 0)) {
      int i = paramWorld.getData(paramInt1, paramInt2, paramInt3);
      if ((i & 0x8) == 0)
        paramWorld.setData(paramInt1, paramInt2, paramInt3, i | 0x8);
      else
        b(paramWorld, paramInt1, paramInt2, paramInt3, paramRandom);
    }
  }

  public int a(int paramInt1, int paramInt2)
  {
    paramInt2 &= 3;
    if (paramInt2 == 1)
      return 63;
    if (paramInt2 == 2) {
      return 79;
    }
    return super.a(paramInt1, paramInt2);
  }

  public void b(World paramWorld, int paramInt1, int paramInt2, int paramInt3, Random paramRandom)
  {
    int i = paramWorld.getData(paramInt1, paramInt2, paramInt3) & 0x3;

    paramWorld.setRawTypeId(paramInt1, paramInt2, paramInt3, 0);
    Object localObject = null;

    if (i == 1) {
      localObject = new WorldGenTaiga2();
    } else if (i == 2) {
      localObject = new WorldGenForest();
    } else {
      localObject = new WorldGenTrees();
      if (paramRandom.nextInt(10) == 0) {
        localObject = new WorldGenBigTree();
      }
    }
    if (!((WorldGenerator)localObject).a(paramWorld, paramRandom, paramInt1, paramInt2, paramInt3))
      paramWorld.setRawTypeIdAndData(paramInt1, paramInt2, paramInt3, this.id, i);
  }

  protected int b(int paramInt)
  {
    return paramInt & 0x3;
  }
}